#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL

    create user nankai with password 'nankai';
    create database nk_emission;
    grant all privileges on database nk_emission to nankai;

    create user keycloak with password 'keycloak';
    create database keycloak;
    grant all privileges on database keycloak to keycloak;

    create user superset with password 'superset';
    create database superset;
    grant all privileges on database superset to superset;

EOSQL

# script_dir=$(cd $(dirname $0); pwd)
# env PGPASSWORD=nankai\
#   psql -v ON_ERROR_STOP=1 --username "nankai" --dbname "nk_emission" --file "${script_dir}/init-user-table.file"
